package sunstar.com.xq.activity

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_multi_image_info.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
import sunstar.com.xq.R
import sunstar.com.xq.databean.CardData

class MultiImageInfoActivity : BaseActivity(),View.OnClickListener {


    override fun setBaseView(): Int = R.layout.activity_multi_image_info

    override fun setTitleText(): String =""

    override fun showTitle(): Boolean = false
    var imgList = mutableListOf<ImageView>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setView()
    }
    var data:CardData?= null
    private fun setView() {
        data = intent.getSerializableExtra("data") as CardData
        var finalString = data!!.cardImg.split(",")
        imgList.add(multi_img_img1)
        imgList.add(multi_img_img2)
        imgList.add(multi_img_img3)
        imgList.add(multi_img_img4)
        imgList.add(multi_img_img5)
        imgList.add(multi_img_img6)

        for (i in 0 .. finalString.size-1){
            Picasso.with(this).load(finalString[i]).into(imgList[i])
            imgList[i].setOnClickListener(this)
        }
        if(finalString.size!=6){
            for (i in finalString.size-1 .. 5){
                imgList[i].visibility = View.GONE
            }
        }



    }
    override fun onClick(v: View?) {
        var id = v?.id
        when (id){
            R.id.multi_img_img1 ->{
                startActivity<ImageCheckActivity>("data" to data!!)
            }
            R.id.multi_img_img2 ->{}
            R.id.multi_img_img3 ->{}
            R.id.multi_img_img4 ->{}
            R.id.multi_img_img5 ->{}
            R.id.multi_img_img6 ->{}


        }
    }
}
